<?php
/*
 * Created on 2016/11/26
 *
 * To change the template for this generated file go to
 * Window - Preferences - PHPeclipse - PHP - Code Templates
 */
 session_start();
 require_once('../db/properties.inc.php');
 $userInfo = $_SESSION["userInfo"]; 
 $userObj = json_decode($userInfo);//用户信息
 if(!$userInfo){
 	header("Location: ../../view/login.html");
 	exit;
 }
 
 $city = $_POST["city"];
 $fatherId = $_POST["fatherId"];      
 
 //保存用户头像
 try {
 	 $conn = new mysqli($url, $user, $pwd, $dbname, $port);
	 $conn -> set_charset("utf8");
	 if (mysqli_connect_errno()) {
	 	echo "0";
	    exit;
	 }
	 $sql = "";
	 if($city=="province"){
	 	$sql = "SELECT t.provinceID,t.province FROM hatProvince t";
	 }else{
	 	$sql = "SELECT t.cityID as provinceID,t.city as province FROM hatCity t WHERE t.provinceid='".$fatherId."'";
	 }
	 $result = array();
	 $results = $conn->query($sql);
	 while ($row = $results->fetch_assoc()) {
      	$result[] = $row;
     }
     $conn -> close();
	 echo json_encode($result,JSON_UNESCAPED_UNICODE);
	 exit;
 }catch( Exception $e ) {
 	 echo "0";
 	 exit;
 }
?>
